﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TicTacToe;
namespace TicTacToe
{
    class TicTacToeButton : System.Windows.Forms.Button
    {
        public delegate void TicTacToeClick(TicTacToeButton sender);
        public event TicTacToeClick OnTicClick;
        private int x;
        public int X
        {
            get { return this.x; }
        }
        private int y;
        public int Y
        {
            get { return this.y; }
        }
        private TicTacToeValue value;
        public TicTacToeValue Value
        {
            get
            {
                return this.value;
            }
            set
            {
                this.value = value;
                switch (this.value)
                {
                    case TicTacToeValue.X:
                        this.Text = "X";
                        break;
                    case TicTacToeValue.O:
                        this.Text = "O";
                        break;
                    case TicTacToeValue.NONE:
                        this.Text = "";
                        break;
                }
            }
        }
        public TicTacToeButton(int x, int y)
        {
            this.x = x;
            this.y = y;
            this.Click += new System.EventHandler(this.HandleButton);
        }
        private void HandleButton(object sender, EventArgs args)
        {
            if(this.OnTicClick != null)
                this.OnTicClick(this);
        }
    }
}
